import {Navigate} from 'react-router-dom';
import {useSelector} from 'react-redux'
//鉴权组件
function Author(props){
    // 判断当前用户是否已经登录
    // let userToken = localStorage.getItem('USER_TOKEN');
    let userToken  = useSelector((state)=>{
        return state.tokenReducer.token
    })
    if(userToken){
         return (
             <div>{props.OldComponent}</div>
         )
    }
    return <Navigate to='/login' />
}

export default Author;